package com.carrie.mdg.myviewtext.activity;

import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.carrie.mdg.myviewtext.R;

import androidLib.activity.BaseActivity;

public class WidgetTextActivity extends BaseActivity {
    private Button btn_alertdialog, btn_progressdialog;

    public static void actionStart(Context context) {
        Intent intent = new Intent(context, WidgetTextActivity.class);
        context.startActivity(intent);
    }


    @Override
    protected void initVariables() {

    }

    @Override
    protected void initViews(Bundle savedInstanceState) {
        setContentView(R.layout.activity_widget_text);
        btn_alertdialog = (Button) findViewById(R.id.button_show_alert_dialog);
        btn_progressdialog = (Button) findViewById(R.id.button_show_progressdialog);
    }

    @Override
    protected void initEvent() {
        btn_alertdialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final AlertDialog.Builder builder = new AlertDialog.Builder(WidgetTextActivity.this);
                builder.setTitle("This is a alert dialog");
                builder.setMessage("alert");
                builder.setCancelable(true);
                builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                builder.show();
            }
        });
        btn_progressdialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ProgressDialog progressDialog = new ProgressDialog(WidgetTextActivity.this);
                progressDialog.setTitle("This is a progress dialog");
                progressDialog.setMessage("loading...");
                progressDialog.setCancelable(true);
                progressDialog.show();
            }
        });
    }

    @Override
    protected void loadData() {

    }
}
